package de.hhkk.view.stammdaten;

import org.eclipse.nebula.widgets.calendarcombo.CalendarCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;

public class UIKursdatenNeuanlage extends Composite
{
    private Text text;
    private Text text_1;
    private Text text_2;
    private Text text_3;

    // static fields to hold the images

    /**
     * Create the composite.
     * @param parent
     * @param style
     */
    public UIKursdatenNeuanlage(Composite parent, int style, String title)
    {
        super(parent, style);
        setLayout(new FillLayout(SWT.HORIZONTAL));

        TabFolder tabFolder = new TabFolder(this, SWT.NONE);
        TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
        tabItem.setText(title);

        SashForm sashForm = new SashForm(tabFolder, SWT.VERTICAL);
        tabItem.setControl(sashForm);

        Group grpSuchkriterien = new Group(sashForm, SWT.NONE);
        grpSuchkriterien.setText("Kursdaten");
        grpSuchkriterien.setLayout(new GridLayout(5, false));

        Label lblName = new Label(grpSuchkriterien, SWT.NONE);
        lblName.setText("Name");

        text = new Text(grpSuchkriterien, SWT.BORDER);
        GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_text.widthHint = 140;
        text.setLayoutData(gd_text);

        Label lblTrainer = new Label(grpSuchkriterien, SWT.NONE);
        lblTrainer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblTrainer.setText("Trainer");

        text_2 = new Text(grpSuchkriterien, SWT.BORDER);
        GridData gd_text_2 = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_text_2.widthHint = 142;
        text_2.setLayoutData(gd_text_2);
        new Label(grpSuchkriterien, SWT.NONE);

        Label lblDatumVon = new Label(grpSuchkriterien, SWT.NONE);
        lblDatumVon.setText("Datum");

        CalendarCombo calendarCombo = new CalendarCombo(grpSuchkriterien, SWT.NONE);

        Label lblDatumBis = new Label(grpSuchkriterien, SWT.NONE);
        lblDatumBis.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblDatumBis.setText("Uhrzeit");

        CalendarCombo calendarCombo_1 = new CalendarCombo(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);

        Label lblAnzahlTeilnehmer = new Label(grpSuchkriterien, SWT.NONE);
        lblAnzahlTeilnehmer.setText("Anzahl Teilnehmer");

        text_1 = new Text(grpSuchkriterien, SWT.BORDER);
        // Nur Zahlen erlauben
        text_1.addListener(SWT.Verify, new Listener()
        {
            @Override
            public void handleEvent(Event e)
            {
                String string = e.text;
                char[] chars = new char[string.length()];
                string.getChars(0, chars.length, chars, 0);
                for (int i = 0; i < chars.length; i++)
                {
                    if (!('0' <= chars[i] && chars[i] <= '9'))
                    {
                        e.doit = false;
                        return;
                    }
                }
            }
        });

        GridData gd_text_1 = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_text_1.widthHint = 69;
        text_1.setLayoutData(gd_text_1);

        Label lblSprache = new Label(grpSuchkriterien, SWT.NONE);
        lblSprache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblSprache.setText("Sprache");

        Combo combo = new Combo(grpSuchkriterien, SWT.NONE);
        combo.setItems(new String[]{"Deutsch", "Englisch", "Franz\u00F6sisch"});
        combo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
        new Label(grpSuchkriterien, SWT.NONE);

        Label lblNewLabel = new Label(grpSuchkriterien, SWT.NONE);
        lblNewLabel.setText("Grundkenntnisse");

        text_3 = new Text(grpSuchkriterien, SWT.BORDER);
        GridData gd_text_3 = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_text_3.widthHint = 149;
        text_3.setLayoutData(gd_text_3);

        Label lblNewLabel_1 = new Label(grpSuchkriterien, SWT.NONE);
        lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel_1.setText("Bootstyp");

        Combo combo_1 = new Combo(grpSuchkriterien, SWT.NONE);
        combo_1.setItems(new String[]{"Segelboot Typ1", "Segelboot Typ2", "Segelboot Typ3", "Segelboot Typ4"});
        combo_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);
        new Label(grpSuchkriterien, SWT.NONE);

        Button btnSuchen = new Button(grpSuchkriterien, SWT.NONE);
        btnSuchen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        btnSuchen.setText("Speichern");

        Button btnSchlieen = new Button(grpSuchkriterien, SWT.NONE);
        btnSchlieen.setText("Schlie\u00DFen");
        sashForm.setWeights(new int[]{151});

        //		 table.addListener(SWT.MouseDown, new Listener() {
        //		      public void handleEvent(Event event) {
        //		    	  int columnCount = 5;
        //		        Rectangle clientArea = table.getClientArea();
        //		        Point pt = new Point(event.x, event.y);
        //		        int index = table.getTopIndex();
        //		        while (index < table.getItemCount()) {
        //		          boolean visible = false;
        //		          TableItem item = table.getItem(index);
        //		          for (int i = 0; i < columnCount; i++) {
        //		            Rectangle rect = item.getBounds(i);
        //		            if (rect.contains(pt)) {
        //		              Logger.getLogger(getClass()).debug("Item " + index + "-" + i);
        //		            }
        //		            if (!visible && rect.intersects(clientArea)) {
        //		              visible = true;
        //		            }
        //		          }
        //		          if (!visible)
        //		            return;
        //		          index++;
        //		        }
        //		      }
        //		    });
    }

    @Override
    protected void checkSubclass()
    {
        // Disable the check that prevents subclassing of SWT components
    }
}
